<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="姓名" v-model="name">
  <input type="text" placeholder="工资" v-model="salary">
  <input type="text" placeholder="工作" v-model="job">
  <input type="button" value="添加" @click="f()">

  <table border="1">
    <caption>员工列表</caption>
    <tr>
      <th>姓名</th>
      <th>工资</th>
      <th>工作</th>
    </tr>
    <tr v-for="emp in arr">
      <td>{{emp.name}}</td>
      <td>{{emp.salary}}</td>
      <td>{{emp.job}}</td>
    </tr>
  </table>
</div>
<!--引入vue-->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v= new Vue({
        el:"body>div",
        data:{
            arr:[
              {name:"老大",salary:3300,job:"保安"},
              {name:"老二",salary:3300,job:"安保"},
              {name:"老三",salary:3300,job:"队长"},],
          name:"",
          salary:"",
          job:""
        },
      methods:{
          f(){
            //创建一个员工对象那输入的信息进行封装
            let emp = {name:v.name,salary:v.salary,job:v.job}
            //把创建的员工对象添加到数组里(push:将对象添加到数组里)
            v.arr.push(emp)
          }
      }
    })
</script>
</body>
</html>